package com.dayang.homemaking.common.core.exception;

import lombok.Getter;

import java.io.Serial;

/**
 * @author: dayang
 * @since: 2024/9/19
 * @description: 自定义业务异常
 */
@Getter
public class BizException extends RuntimeException{
    @Serial
    private static final long serialVersionUID = 4644082017101684426L;
    /**
     * 异常码
     */
    private String errorCode;

    /**
     * 错误信息
     */
    private String errorMessage;


    public BizException(BaseException baseException){
        super(baseException.getErrorMessage());
        this.errorCode = baseException.getErrorCode();
        this.errorMessage = baseException.getErrorMessage();
    }

    public BizException(BaseException baseException,Throwable cause){
        super(baseException.getErrorMessage(),cause);
        this.errorCode = baseException.getErrorCode();
        this.errorMessage = baseException.getErrorMessage();
    }

    public BizException(String errorCode,String errorMessage) {
        super(errorMessage);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

    public BizException(String errorCode,String errorMessage,Throwable cause) {
        super(errorMessage,cause);
        this.errorCode = errorCode;
        this.errorMessage = errorMessage;
    }

}
